import { $get, $delete } from '@js/request'
export interface DataSchema {
  orderno?: number
  'id': string
  'workid': string
  'type': string
  'content': string
  'weights': number
  'self_evaluation_score': number
  'leadership_score': number
  'accountid': string
  'name': string
  'begin_datetime': number
  'end_datetime': number
  'status': number
  'create_datetime': number
  'operator': string
  'operatorid': string
}

// 获取项
export async function getListRequest (workid: string, workType: string): Promise<DataSchema[]> {
  const res = await $get('/api/commission/work_item', {
    workid,
    condition: JSON.stringify([{ k: 'type', o: '=', v: workType }])
  })
  res.data.forEach((li: DataSchema, i: number) => {
    li.orderno = i + 1
  })
  return res.data
}

export async function delRequest (id: string): Promise<void> {
  const res = await $delete(`/api/commission/work_item/${id}`)
  return res.data
}
